package com.itheima.pattern.t7_decorator.demo1;

/**
 * 装饰者模式
 * 在不改变现有对象结构的情况下，动态地给该对象增加一些职责（即增加其额外功能）的模式
 */
public class TestDemo {

    public static void main(String[] args) {
        // 点一份炒饭
        FastFood food = new FriedRice();
        System.out.println(food.getDesc() + " : " + food.cost() + "元");
        System.out.println("=================================");
        // 在上面的炒饭加一个鸡蛋
        food = new Egg(food);
        System.out.println(food.getDesc() + " : " + food.cost() + "元");
        System.out.println("=================================");
        // 再加一个鸡蛋
        food = new Egg(food);
        System.out.println(food.getDesc() + " : " + food.cost() + "元");
        System.out.println("=================================");
        // 再加一个培根
        food = new Bacon(food);
        System.out.println(food.getDesc() + " : " + food.cost() + "元");
    }
}
